Skip to content

feat(bufferbloat): parse, log, and highlight under-load latency + pac…#9

Merged
GoWithitRoger merged 1 commit intomainfrom
feat/bufferbloat-add
Aug 11, 2025
Merged

feat(bufferbloat): parse, log, and highlight under-load latency + pac…#9
GoWithitRoger merged 1 commit intomainfrom
feat/bufferbloat-add

Conversation

@GoWithitRoger
Copy link
Copy Markdown
Owner

…ket loss; compute bufferbloat deltas

Implements Tickets #1#4 to integrate bufferbloat observability, thresholds, parsing, logging, and tests.

  • config.py
    • add LATENCY_UNDER_LOAD_THRESHOLD (ms) and SPEEDTEST_PACKET_LOSS_THRESHOLD (%)
    • add BUFFERBLOAT_DELTA_THRESHOLD (ms) for idle→load delta highlighting
  • main.py
    • SpeedResults: extend TypedDict with:
      • local_latency_down_load_ms, local_latency_up_load_ms, local_packet_loss_pct
    • run_local_speed_test_task():
      • parse Ookla JSON: download.latency.iqm, upload.latency.iqm, packetLoss (with .get defaults)
      • include parsed metrics in return dict
    • log_results():
      • include new fields in CSV: Local_Load_Down_ms, Local_Load_Up_ms, Local_Pkt_Loss_Pct
      • print bufferbloat lines in console with thresholds:
        • Latency (Download Load), Latency (Upload Load), Speedtest Packet Loss
      • add calculated deltas to CSV/console: - Download_Bufferbloat_ms, Upload_Bufferbloat_ms (computed vs idle WAN RTT)
      • consistent float formatting (CSV 3dp; console 2dp for latency, 2dp for %)
    • perform_checks():
      • compute bufferbloat deltas: (under-load latency − idle latency) for down/up
    • run_speed_test_task():
      • improve waiting logic by waiting for the results table (robustness for selenium flow)
    • minor CSV formatting simplification for the data row list comprehension

tests:

  • tests/test_core.py
    • update SPEEDTEST_JSON_OUTPUT to include latency.iqm and packetLoss
    • assert parsing of new metrics
    • add test_local_speed_test_parsing_missing_keys (defaults to 0.0 without crash)
  • tests/test_logging.py
    • extend MOCK_DATA_COMPLETE with new metrics
    • test_log_results_csv_creation: assert headers include new fields; data row contains “75.500”
    • test_log_results_console_output_highlighting:
      • set thresholds for bufferbloat
      • assert red highlighting for anomalous load latencies and packet loss
    • add boundary test (equal-to-threshold NOT highlighted)
    • add precision tests:
      • CSV: 3dp checks for new fields
      • console: 2dp for latency and packet loss
  • tests/test_selenium_tasks.py
    • remains green after switching to table-based wait (ensures stable speed test flow)
    • (adjust mocks to reflect new waiting behavior if needed)

chore: lint, type-check, and verification

  • ty check: All checks passed
  • ruff check: All checks passed
  • pytest: full suite passes locally

Refs: Ticket #1 (config/models), Ticket #2 (Ookla parsing), Ticket #3 (logging/reporting), Ticket #4 (tests)

…ket loss; compute bufferbloat deltas

Implements Tickets #1#4 to integrate bufferbloat observability, thresholds, parsing, logging, and tests.

- config.py
  - add LATENCY_UNDER_LOAD_THRESHOLD (ms) and SPEEDTEST_PACKET_LOSS_THRESHOLD (%)
  - add BUFFERBLOAT_DELTA_THRESHOLD (ms) for idle→load delta highlighting
- main.py
  - SpeedResults: extend TypedDict with:
    - local_latency_down_load_ms, local_latency_up_load_ms, local_packet_loss_pct
  - run_local_speed_test_task():
    - parse Ookla JSON: download.latency.iqm, upload.latency.iqm, packetLoss (with .get defaults)
    - include parsed metrics in return dict
  - log_results():
    - include new fields in CSV: Local_Load_Down_ms, Local_Load_Up_ms, Local_Pkt_Loss_Pct
    - print bufferbloat lines in console with thresholds:
      - Latency (Download Load), Latency (Upload Load), Speedtest Packet Loss
    - add calculated deltas to CSV/console:
      - Download_Bufferbloat_ms, Upload_Bufferbloat_ms (computed vs idle WAN RTT)
    - consistent float formatting (CSV 3dp; console 2dp for latency, 2dp for %)
  - perform_checks():
    - compute bufferbloat deltas: (under-load latency − idle latency) for down/up
  - run_speed_test_task():
    - improve waiting logic by waiting for the results table (robustness for selenium flow)
  - minor CSV formatting simplification for the data row list comprehension

tests:
- tests/test_core.py
  - update SPEEDTEST_JSON_OUTPUT to include latency.iqm and packetLoss
  - assert parsing of new metrics
  - add test_local_speed_test_parsing_missing_keys (defaults to 0.0 without crash)
- tests/test_logging.py
  - extend MOCK_DATA_COMPLETE with new metrics
  - test_log_results_csv_creation: assert headers include new fields; data row contains “75.500”
  - test_log_results_console_output_highlighting:
    - set thresholds for bufferbloat
    - assert red highlighting for anomalous load latencies and packet loss
  - add boundary test (equal-to-threshold NOT highlighted)
  - add precision tests:
    - CSV: 3dp checks for new fields
    - console: 2dp for latency and packet loss
- tests/test_selenium_tasks.py
  - remains green after switching to table-based wait (ensures stable speed test flow)
  - (adjust mocks to reflect new waiting behavior if needed)

chore: lint, type-check, and verification
- ty check: All checks passed
- ruff check: All checks passed
- pytest: full suite passes locally

Refs: Ticket #1 (config/models), Ticket #2 (Ookla parsing), Ticket #3 (logging/reporting), Ticket #4 (tests)
@GoWithitRoger GoWithitRoger merged commit 1ccdcfc into main Aug 11, 2025
1 check passed
@GoWithitRoger GoWithitRoger deleted the feat/bufferbloat-add branch August 11, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant